import React, {Component} from 'react';
import NewIncreased from '../../../../../public/components/NewIncreased'
import FormView from './formView'
import './index.less'
class AddNew extends Component{
    constructor(props) {
        super(props);
        this.state = {
            setModalVisible: false
        }
    }
    // 设置新增弹窗显示隐藏
    setNewIncreasedDis (setModalVisible) {
        this.setState({
            setModalVisible 
        })
    }
    // 下一步方法
    nextHandle (selectData) {
        this.refs.addFormView.nextHandle(selectData)
    }
    // 完成方法 调用新增保存接口
    doneHandle () {
        this.refs.addFormView.doneHandle()
    }
    cancelBtnClick () {
        this.refs.addFormView.cancelBtnClick()
    }
    onClose () {
        this.refs.addFormView.onClose()
    }
    // 上一步的回调
    prevHandle () {
        this.refs.addFormView.prevHandle()
    }
    render () {
        let props = this.props
        return (
            <div className="addNew">
                {
                    this.state.setModalVisible ? 
                    <NewIncreased 
                        setModalVisible={this.state.setModalVisible}
                        prevHandle={this.prevHandle.bind(this)}
                        {...this.props}
                        nextHandle={this.nextHandle.bind(this)}
                        doneHandle={this.doneHandle.bind(this)}
                        onClose={this.onClose.bind(this)}> 
                            <FormView ref="addFormView" {...props} setNewIncreasedDis={this.setNewIncreasedDis.bind(this)}/>
                    </NewIncreased>:                             
                    ''
                }
            </div>
        )
    }
}
export default AddNew